<template>
	<view class="content">
		<view>
			<uni-breadcrumb separator=">">
				<uni-breadcrumb-item v-for="(route,index) in routes" :key="index" :to="route.to">
					{{route.name}}
				</uni-breadcrumb-item>
			</uni-breadcrumb>
		</view>
		<hr>
		<view style="{display: flex;flex-direction: column;}">
			<view class="input-group">
				<input v-model="pwd1" password="true" class="input" type="safe-password" placeholder="设置新密码" />

				<input v-model="pwd2" password="true" type="safe-password" placeholder="请再次输入密码" class="input">
				<button class="btn" @click="Go">完成</button>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		name: "uni-stat-breadcrumb",
		data() {
			return {
				pwd1: '',
				pwd2: '',
				routes: [{
						to: "/pages/login/forgetpwd/forgetpwd",
						name: "1验证手机号码",
					},
					{
						name: "2设置新密码",
					},

				],
			};
		},
		methods: {

			async Go() {
				let that = this;
				const res = await that.$myRequest({
					url: '',
					method: 'PATCH',
					data: {
						pwd1: that.pwd1,
						pwd2: that.pwd2
					},
				})
				console.log(res)
				// 如果请求成功，则弹出提示语 "修改成功" 不懂showToast用法可以搜
				if (res.success) {
					uni.showToast({
						icon: "none",
						title: "修改成功"
					})
					// removeStorageSync: 从本地缓存中同步移除指定 token
					uni.removeStorageSync('usertoken');
					// redirectTo ：跳转 
					uni.redirectTo({
						url: '/pages//login/login'
					})

				} else {
					uni.showToast({
						icon: "none",
						title: "修改失败"
					})
				}

			}

		}
	};
</script>

<style lang="scss" scoped>
	.input-group {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin: 0 $uni-spacing-row-lg;

		.input {
			border: 1px solid $uni-border-color;
			border-top: none;
			border-left: none;
			border-right: none;
			border-radius: $uni-border-radius-base;
			width: 100%;
			height: $uni-font-size-lg * 3;
			color: #000;
		}

		.btn {
			margin: $uni-spacing-col-lg*2.5 $uni-spacing-row-lg*1.5 0;
			background: blue;
			color: $uni-text-color-inverse;

			&:active {
				background-color: darken(blue, 5%);
			}

			width: 100%;
		}
	}
</style>
